package com.zxy.controller;

import com.zxy.result.CommonResult;
import com.zxy.service.AccountService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @author: Zxy
 * @description:
 * @date: 2021-08-21 14:14
 */
@RestController
public class AccountController {

    @Resource
    private AccountService accountService;

    /**
     * 调用账户微服务做账户的余额的扣减操作
     *
     * @param userId 用户id
     * @param money  需要扣除的金额
     */
    @PostMapping(value = "/account/decrease")
    CommonResult decrease(@RequestParam("userId") Long userId,
                          @RequestParam("money") BigDecimal money) {
        accountService.decrease(userId, money);
        return new CommonResult(200, "用户余额扣减成功");
    }

}
